package com.sd365.permission.centre.service;

import com.sd365.permission.centre.pojo.dto.BlackOrWhiteDTO;
import com.sd365.permission.centre.pojo.query.BlackOrWhiteQuery;
import com.sd365.permission.centre.pojo.vo.BlackOrWhiteVO;
import org.springframework.cache.annotation.CacheConfig;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.CachePut;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;

import java.util.List;

@CacheConfig(cacheNames = "BlackOrWhiteService",cacheManager = "BlackOrWhiteService")
public interface BlackOrWhiteService {


    List<BlackOrWhiteVO> commonQuery(BlackOrWhiteQuery blackOrWhiteQuery);

    @CachePut(key = "#p0.blackOrWhiteAccount")
    BlackOrWhiteVO add(BlackOrWhiteDTO blackOrWhiteDTO);


    Boolean remove(Long id, Long version);

    @Transactional
    Boolean batchRemove(BlackOrWhiteDTO[] blackOrWhiteDTOS);

    /**
     * 借助该方法删除key
     * @param account
     * @return
     */
    @CacheEvict(key = "#p0")
    public Boolean removeCache(String account) ;
    /**
     * @param:
     * @return:
     * @see
     * @since
     */
    @CachePut(key = "#p0.blackOrWhiteAccount")
    @Transactional
    Boolean modify(BlackOrWhiteDTO blackOrWhiteDTO);

    /**
     * @param blackOrWhiteDTO
     * @return
     * @author LSL
     * @date 2020/12/17 10:28
     * @version 0.0.1
     */
    @Transactional
    Boolean batchModify(BlackOrWhiteDTO[] blackOrWhiteDTO);

    @Cacheable(key = "#p0")
    BlackOrWhiteDTO queryById(Long id);

    @Cacheable(key = "#p0.id")
    BlackOrWhiteVO queryTest(BlackOrWhiteQuery query);

    /**
     * 批量插入
     *
     * @param
     * @return
     */
    @PostMapping(value = "/batchadd")
    Boolean batchAdd(@RequestBody List<BlackOrWhiteDTO> blackOrWhiteDTOList);
}
